LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

entity tone is
port(
     index:in STD_LOGIC_VECTOR(7 downto 0);
	  code:out STD_LOGIC_VECTOR(6 downto 0);
	  high:out STD_LOGIC;
	  tone0:out INTEGER range 0 to 47781);
end tone;




architecture art of tone is
begin


process(index)
begin
 case index is    -- =>表示的是对应关系
   when "00000001"=> tone0 <=4776;code<="1001111";high<='1';  --不同的数字表示不同的频率，对应不同的音，对应关系是tone0就是tone0*2分频
	when "00000010"=> tone0 <=4256;code<="0010010";high<='1';  --code应该锁数码管的引脚，对应的音符就可以在数码管上显示出来，e.g.do就显示1
	when "00000100"=> tone0 <=3791;code<="0000110";high<='1'; 
	when "00001000"=> tone0 <=3578;code<="1001100";high<='1';  
	when "00010000"=> tone0 <=3188;code<="0100100";high<='1';  --
	when "00100000"=> tone0 <=2840;code<="0100000";high<='0';  --6灭一个管
	when "01000000"=> tone0 <=2530;code<="0001111";high<='0';  --7就是亮三个管
	when "10000000"=> tone0 <=5061;code<="0000000";high<='0';  --8就应该全亮
	when others =>tone0<=4776;code<="0000001";high<='0';
  end case;
end process;
end art;
 